package com.zhiyou100.crm.servlet.customerState;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import com.zhiyou100.crm.service.CustomerStateService;
import com.zhiyou100.crm.service.impl.CustomerStateServiceImpl;
import com.zhiyou100.crm.util.AdminBaseServlet;
import com.zhiyou100.crm.util.CustomerState;


@WebServlet("/customerState/list")
public class ListServlet extends AdminBaseServlet {
	private static final long serialVersionUID = 1L;
    CustomerStateService customerStateService=new CustomerStateServiceImpl();

	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		response.setContentType("text/html; charset=UTF-8");
		List<CustomerState> customerStates = customerStateService.query();
		if(customerStateService!=null){
			request.setAttribute("list",customerStates);
			request.getRequestDispatcher("/WEB-INF/view/customerState/list.jsp").forward(request, response);
		}else {
			response.sendRedirect(request.getContextPath()+"/WEB-INF/view/customerState/list.jsp");
		}

	}

}
